import { lazy, Suspense } from 'react'
import { Routes, Route, useLocation } from "react-router-dom";
import NotFound from 'src/components/NotFound'
import RouterView from './RouterView'
const Portal = lazy(() => import('src/pages/Portal'))

function RootRouter() {
    const location = useLocation();
    const { pathname } = location;

    return <>
        {
            pathname.startsWith('/portal') ? <Routes>
                <Route
                    path="portal/*"
                    element={
                        <Suspense fallback={null}>
                            <Portal />
                        </Suspense>
                    } />
                <Route path="*" element={<NotFound />} />
            </Routes> : <RouterView />
        }
    </>
}

export default RootRouter